// 默认的卡号脱敏规则
export function formatCardNum(num, char = ' *** ') {
	let value = ''
	num += '';
	// for (let i = 0, len = num.length - 2; i < len; i++) {
	// 	char += '*'
	// }
	value = num.substr(0, 4) + char + num.substr(-4, 4);
	return value
}

/*
Promise 超时机制
 */
export function promiseTimeOut(promise, ms = 5000, sign = '') {
	var timeout = delayPromise(ms).catch(() => {
		throw new Error('Operation timed out after ' + ms + ' ms' + ' in ' + sign);
	});

	return Promise.race([timeout, promise])
}

export default {
	formatCardNum,
	promiseTimeOut
}
